using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Joy.Erp.BasicArchives.Core.Filters;

namespace Joy.Erp.BasicArchives.Customers
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("CustomerType")]
    [Route("api/basic-archives/customer-type")]
    public partial class CustomerTypeController : BasicArchivesController, ICustomerTypeAppService
    {
        protected ICustomerTypeAppService CustomerTypeAppService => LazyServiceProvider.LazyGetRequiredService<ICustomerTypeAppService>();

        [HttpGet]
        [Route("{id}")]
        public Task<CustomerTypeDto> GetAsync(Guid id)
        {
            return CustomerTypeAppService.GetAsync(id);
        }

        [HttpGet]
        [Route("find")]
        public Task<CustomerTypeDto> FindAsync(string filter)
        {
            return CustomerTypeAppService.FindAsync(filter);
        }

        [HttpGet]
        [Route("find-by-source-key")]
        public Task<CustomerTypeDto> FindBySourceKeyAsync(string sourceKey, string sourceType)
        {
            return CustomerTypeAppService.FindBySourceKeyAsync(sourceKey, sourceType);
        }

        [HttpGet]
        public Task<PagedResultDto<CustomerTypeDto>> GetListAsync(FilterRequestDto input)
        {
            return CustomerTypeAppService.GetListAsync(input);
        }

        [HttpPost]
        [Route("query")]
        public Task<PagedResultDto<CustomerTypeDto>> QueryAsync(FilterGroupRequestDto input)
        {
            return CustomerTypeAppService.QueryAsync(input);
        }

        [HttpPost]
        [Route("get-children")]
        public Task<ListResultDto<CustomerTypeDto>> GetChildrenAsync(Guid? parentId, bool recursive = false)
        {
            return CustomerTypeAppService.GetChildrenAsync(parentId, recursive);
        }

        [HttpPost]
        public Task<CustomerTypeDto> CreateAsync(CustomerTypeCreateDto input)
        {
            return CustomerTypeAppService.CreateAsync(input);
        }

        [HttpPut]
        [Route("{id}")]
        public Task<CustomerTypeDto> UpdateAsync(Guid id, CustomerTypeUpdateDto input)
        {
            return CustomerTypeAppService.UpdateAsync(id, input);
        }

        [HttpDelete]
        [Route("{id}")]
        public Task DeleteAsync(Guid id)
        {
            return CustomerTypeAppService.DeleteAsync(id);
        }
    }
}